const express = require('express')
// npm install axios 
const axios = require('axios')
const app = express()
const router = express.Router()
// 导入你的代理  
const proxies = require('./config/proies')

proxies.forEach(item => {
    // console.log(proxy)
    router.use(item.source, async (req,res) =>{
        const result = await axios({
            url:item.target,
            method:req.method,
            body:req.body,
            data:req.query,
        })

        res.send(result.data)
    })
})
// 
// 让代理起作用 





app.use('/static', express.static('./client/'))
app.use(router)
app.listen(8080, () => console.log('我是静态资源服务器, 开启成功, 端口号 8080'))
